***Deprivation in the Midst of Plenty: Citizen Polarization and Political Protest***
***John D. Griffin1* , Chad Kiewiet de Jonge and Vania Ximena Velasco-Guachalla***
***Accepted 2019***

***REPLICATION FILES***
* use polarization data

sort ccode Year
*Merging with Conflict Data
merge 1:1 ccode Year using "Conflict data sample.dta"
tab _merge
drop _merge
*Merge with Quality of Government Data
sort ccode Year
merge 1:1 ccode Year using "QOG sample.dta"
tab _merge
drop _merge

tostring Year, generate(Year_str)

forval i=1(2)3 {
	gen Year_`i'=substr(Year_str, `i', 2)
	}

egen CY2=concat(country2 Year_3)

*Transforming polarization and satisfaction measure
replace polar=polar*100
replace disat=disat*100

*protest variables
gen protest01=protest>0
replace protest01=. if protest==.

gen protest3=0
replace protest3=1 if protest>0
replace protest3=2 if protest>1
replace protest3=. if protest==.

*** control variables
sort Country Year
*gini -inequality variable
ipolate solt_ginet Year, generate(gini) by(Country)
*gen gini=solt_ginet
bysort Country: carryforward gini,  gen(gini_b)
bysort Country: carryforward gini_b,  replace back
**GDP
gen GDPcap=ln(pwt_rgdpch)
gen Growth=wdi_gdpgr
gen Inflation=wdi_infl
gen Ln_Inflation=ln(Inflation) if Inflation>=1
replace Ln_Inflation=0 if Inflation<1
gen polity2=p_polity2
gen Eth_frag=al_ethnic
gen Ln_pop=ln(wdi_pop)
gen Elec_leg=dpi_legelec
gen Elec_exe=dpi_exelec
gen ENP=gol_enpp
gen Presidential=dpi_system==0
gen Urban=wdi_urban
gen reg_durability=p_durable
gen terror=gd_ptss

drop if polity2<0
drop if polity2==.

gen timetrend=Year-2000

**Generating the variable for nonviolent and violent protest**
gen allprotest=.
replace allprotest= riot + protest
br protest riot demons allprotest

* summary stats
sum  disat  polar  protest  gini   GDPcap Growth  Ln_Inflation Elec_leg Elec_exe polity2 reg_durability     terror  Urban Ln_pop Presidential  Eth_frag timetrend

**** generate centered and lagged variables
foreach var of varlist protest allprotest polar disat gini gini_b GDPcap Growth Inflation Ln_Inflation Elec_leg Elec_exe polity2 reg_durability     terror  Urban Ln_pop protest01 m_SWD sd_SWD {
	sort Country Year
	egen m_`var'=mean(`var')
	gen c_`var'=`var'-m_`var'
	gen l_`var'=c_`var'[_n-1]
	*gen l_`var'=`var'[_n-1]
	*gen lc_`var'=c_`var'[_n-1]
}

keep if polar!=. | (l_polar!=.)

corr sd_SWD polar

***Figure 2 : Scatterplot of grievance and polarization, by country-year and country averages

encode Country, gen(Country_id)
sort Country Year
bysort Country: gen Country_n=_n

egen mu_polar=mean(polar), by(Country_id)
egen mu_disat=mean(disat), by(Country_id)

pwcorr disat polar, sig
pwcorr mu_disat mu_polar, sig

twoway (scatter polar disat, mcolor(gs7) msize(vsmall) msymbol(none) mlabel(CY2) mlabsize(tiny) mlabcolor(gs9) mlabposition(0)) (scatter mu_polar mu_disat if Country_n==1 , msymbol(none) mlabel(country3) mlabsize(vsmall) mlabcolor(black) mlabposition(0)), ytitle(Polarization) ylabel(35(10)85) xtitle(Grievances) xlabel(40(10)90) legend(off) graphregion(color(white))

****TABLE 1 MODELS -PREDICTING POLITICAL PROTEST
*without disat or polar / no RE
nbreg protest l_protest l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend if e(sample), cluster(Country)

*wihtout disat or polar / with RE
menbreg protest l_protest l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend if e(sample) || Country: , 

*With disat or polar / no RE
nbreg protest l_protest  l_polar l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend, cluster(Country) 

*With disat or polar/ with RE
menbreg protest l_protest  l_polar l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend || Country: 

*with interaction/ no RE
nbreg protest l_protest  l_polar l_disat c.l_polar#c.l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend, cluster(Country)

*with interaction/ with RE
menbreg protest l_protest  l_polar l_disat c.l_polar#c.l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban  l_Ln_pop Presidential  Eth_frag timetrend || Country: , 


*FIGURE 3
*with polar/disat + interaction
nbreg protest l_protest  l_polar l_disat c.l_polar#c.l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend, cluster(Country) 
* at -1.5 sd grievance
 margins, noatlegend predict(pr(1,1000))    at((means) _all  l_disat=-12.8  timetrend=(0) l_polar=(-12.5 -6.25 0 6.25 12.5)) post
est store model1
 
* at 1.5 sd grievance
nbreg protest l_protest  l_polar l_disat c.l_polar##c.l_disat l_gini c.l_gini#c.l_gini  l_GDPcap l_Growth  l_Ln_Inflation l_Elec_leg l_Elec_exe l_polity2 l_reg_durability     l_terror  l_Urban l_Ln_pop Presidential  Eth_frag timetrend, cluster(Country) 
 margins, noatlegend predict(pr(1,1000))    at((means) _all  l_disat=12.8  timetrend=(0) l_polar=(-12.5 -6.25 0 6.25 12.5)) post
est store model2
coefplot model1 model2, at xtitle(" ") noci lwidth(*1) connect(l)
 

**TABLE OF CORRELATIONS**
estpost correlate protest polar disat gini GDPcap Growth Ln_Inflation Elec_leg Elec_exe polity2 reg_durability terror Urban Ln_pop Presidential  Eth_frag
esttab using corr.rtf, unstack  not noobs compress
estpost correlate polar protest disat gini GDPcap Growth Ln_Inflation Elec_leg Elec_exe polity2 reg_durability terror Urban Ln_pop Presidential  Eth_frag
esttab using corr1.rtf, unstack  not noobs compress
estpost correlate disat polar protest gini GDPcap Growth Ln_Inflation Elec_leg Elec_exe polity2 reg_durability terror Urban Ln_pop Presidential  Eth_frag
esttab using corr2.rtf, unstack  not noobs compress


